#ifndef SimpleChannel_H
#define SimpleChannel_H

#include "QStorableObject.h"

#include <QPropertyAnimation>

//typedef QSharedPointer<QWidget*> QWidgetPtr;
typedef QHash<QString,QWidget*> WidgetHash;

class SimpleChannel : public QStorableObject
{
	Q_OBJECT
	
	Q_PROPERTY(QString name READ name WRITE setName);
	Q_PROPERTY(int num READ num WRITE setNum);
	Q_PROPERTY(int value READ value WRITE setValue);
public:
	SimpleChannel(QString chanName="", int num=1, int value=0)
		: QStorableObject()
		, m_name(chanName)
		, m_num(num)
		, m_value(value)
		, m_valueAnim(0)
	{}
	
	QString name()	{ return m_name; }
	int num()	{ return m_num; }
	int value()	{ return m_value; }
	
	WidgetHash widgets() { return m_widgets; }
	void setWidgets(WidgetHash hash) { m_widgets = hash; }
	
	QPropertyAnimation *valueAnim() 
	{
		if(!m_valueAnim)
			m_valueAnim = new QPropertyAnimation(this, "value");
		return m_valueAnim;
	}
	//void setValueAnim(QPropertyAnimation *anim) { m_valueanim = anim; }
	
	static bool comparitor(SimpleChannel *a, SimpleChannel *b)
	{
		return a->num() < b->num();
	}

	
public slots:
	virtual void setName(QString name)	{ m_name = name;	emit nameChanged(name);		emit changed(); }
	virtual void setNum(int num)		{ m_num = num;		emit numChanged(num);		emit changed(); }
	virtual void setValue(int value)	{ m_value = value;	emit valueChanged(value);	emit changed(); }

signals:
	void nameChanged(QString name);
	void numChanged(int num); 
	void valueChanged(int value);
	void changed();
	
protected:
	QString m_name;
	int m_num;
	int m_value;
	
	WidgetHash m_widgets;
	QPropertyAnimation *m_valueAnim;
};



#endif
